home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 17 / CU Amiga Magazine's Super CD-ROM 17 (1997)(EMAP Images)(GB)[!][issue 1997-12].iso / CUCD / Programming / DiceSource / master / Examples / Visual / VMake / vmake.h < prev   
C/C++ Source or Header  |  1994-02-01  |  14KB  |  311 lines

  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <sys/stat.h>
  4. #include <string.h>
  5. #include <ctype.h>
  6. #include <workbench/startup.h>
  7. #include <workbench/workbench.h>
  8. #include <workbench/icon.h>
  9. #include <proto/exec.h>
  10. #include <proto/graphics.h>
  11. #include <proto/intuition.h>
  12. #include <proto/gadtools.h>
  13. #include <proto/dos.h>
  14. #include <proto/wb.h>
  15. #include <proto/icon.h>
  16. #include <proto/asl.h>
  17. #include <libraries/gadtools.h>
  18. #include <intuition/intuitionbase.h>
  19. #include <exec/memory.h>
  20. #include <lib/rexx.h>
  21. #include <libraries/asl.h>
  22. #include "renderinfo.h"
  23. #include "defaultfonts.h"
  24. #undef GLOBAL
  25.  
  26. #define ALT_CONFIG_FILE "DCC_Config:VMake.config"
  27. #define CONFIG_FILE "DCC:Config/VMake.config"
  28.  
  29. struct XMenu {
  30.    struct Menu      menu;
  31.    APTR             userdata;
  32.    struct Image     image;
  33. };
  34.  
  35. struct XItem {
  36.    struct MenuItem  item;
  37.    APTR             userdata;
  38.    struct IntuiText itext;
  39. };
  40.  
  41. extern struct Library        *GadToolsBase;
  42. extern struct Library        *AslBase;
  43. extern struct ExecBase       *SysBase;
  44. extern struct IntuitionBase  *IntuitionBase;
  45. extern struct GfxBase        *GfxBase;
  46. extern struct Library        *ArpBase;
  47.  
  48. #define MAX_LIST       35   /* Number of items to display in a list        */
  49. #define MAX_MENU       64   /* Largest number of menu items to allow       */
  50. #define MAX_BUTTON      5
  51. #define MAX_TITLE      64
  52.  
  53. #define MENU_END   NM_END   /* Indicates the last item in a menu           */
  54. #define MENU_MENU NM_TITLE  /* Indicates a menu entry (with subitems)      */
  55. #define MENU_ITEM NM_ITEM   /* Indicates a menu item                       */
  56. #define MENU_SUB   NM_SUB   /* Indicates a submenu item                    */
  57. #define MENU_BAR        4   /* Used for a bar between menu items           */
  58.  
  59. #define MAX_STRING     64   /* Largest allowable string                    */
  60. #define MAX_FILENAME  255   /* Longest possible file name                  */
  61. #define CBUF_SIZE_20 2000   /* Command buffer size for Dos 2.0 and higher  */
  62. #define CBUF_SIZE_13  200   /* Command buffer size for Dos 1.3             */
  63.  
  64. #define MODE_OUT        0
  65. #define MODE_IN         1
  66.  
  67. #define MARGIN_TOP      4
  68. #define MARGIN_BOTTOM   3
  69. #define MARGIN_MID      4
  70.  
  71. #define MARGIN_LEFT     8
  72. #define MARGIN_RIGHT    8
  73. #define RESIZE_WIDTH   14
  74.  
  75. #define VBAR            2   /* Pixel width of a vertical BAR               */
  76. #define DVBAR    (2*VBAR)   /* Pixel width of two vertical BARs            */
  77. #define HBAR            1   /* Pixel height of a horizontal BAR            */
  78. #define DHBAR    (2*HBAR)   /* Pixel height of two Horizontal BARs         */
  79.  
  80. #define CYC_ICON_WIDTH 24
  81.  
  82. #define CHECK_WIDTH    26
  83. #define CHECK_HEIGHT   11
  84.  
  85. #define BUTTON_WIDTH   80
  86.  
  87. #define CLASS_MASK    255   /* lower 8 bits are used for gadget class      */
  88. #define SUBCLASS_OFF    8   /* Upper 8 bits available for sub index        */
  89. #define SUBCLASS_BIT 1<<SUBCLASS_OFF
  90.  
  91. #define STATE_MASK    127   /* allow 7 bits to be used for state           */
  92. #define DIRTY_BIT    1<<7   /* lives in upper bit of G_OBJ.state           */
  93.  
  94. #define CLASS_STRING    1
  95. #define CLASS_CYCLE     2
  96. #define CLASS_CHECK     3
  97. #define CLASS_LIST      4
  98. #define CLASS_BUTTON    5
  99. #define CLASS_ADD       6   /* Not really a gadget type                    */
  100. #define CLASS_DEL       7   /* Not really a gadget type                    */
  101. #define CLASS_UP        8   /* Not really a gadget type                    */
  102. #define CLASS_DOWN      9   /* Not really a gadget type                    */
  103. #define CLASS_PROP     10   /* Not really a gadget type                    */
  104. #define CLASS_REFRESH  14   /* Fake a refresh event                        */
  105. #define CLASS_SELECT   15   /* Not a gadget type - do a list selection     */
  106. #define CLASS_LTOP     16   /* Not a gadget type - select top of list      */
  107. #define CLASS_LBOT     17   /* Not a gadget type - select bottom of list   */
  108. #define CLASS_LUP      18   /* Not a gadget type - select item above       */
  109. #define CLASS_LDN      19   /* Not a gadget type - select item below       */
  110.  
  111. #define TEXT_NEW        0
  112. #define TEXT_DEL        1
  113. #define TEXT_OK         2
  114. #define TEXT_CANCEL     3
  115. #define TEXT_CO         4   /* Check Out Button                               */
  116. #define TEXT_SAVE       5   /* Save Project Button                            */
  117.  
  118. #define TEXT_PROJECT    6   /* Project:                                       */
  119. #define TEXT_NOPROJECT  7   /* No Current Project                             */
  120.  
  121. #define TEXT_SCRIPTCO   8   /* Script is READ-ONLY.  Check out from RCS?      */
  122. #define TEXT_BADFILE    9   /* Unable to open the file                        */
  123. #define TEXT_IOERR     10   /* Error while accessing file                     */
  124. #define TEXT_ASKCO     11   /* File is READ-ONLY.  You will not ... change it */
  125. #define TEXT_ASKKILL   12   /* WARNING: This will REPLACE an existing project */
  126. #define TEXT_ASKSAVE   13   /* WARNING: Project has been changed, .. be lost  */
  127. #define TEXT_BADCMD    14   /* Invalid command                                */
  128. #define TEXT_NOSEL     15   /* Nothing is selected to operate on              */
  129. #define TEXT_NOMEM     16   /* Not enough memory                              */
  130. #define TEXT_BADPROJ   17   /* Invalid project name                           */
  131. #define TEXT_NOPROJ    18   /* No project currently open                      */
  132. #define TEXT_BUFFOVFL  19   /* Not enough room in command buffer              */
  133. #define TEXT_SELFAIL   20   /* Unable to select requested item                */
  134. #define TEXT_BADPARM   21   /* Invalid or missing parm to command             */
  135. #define TEXT_BADRMODE  22   /* Rexx mode must be "on" or "off"                */
  136.  
  137. #define NUM_TEXT       23   /* For range checking                             */
  138.  
  139. #define CONFIG_BASE    NUM_TEXT        /* No gaps after last TEXT_ entry!             */
  140. #define CONFIG_CONSOLE CONFIG_BASE+0   /* Console to use for executing commands       */
  141. #define CONFIG_PATTERN CONFIG_BASE+1   /* File requester pattern                      */
  142. #define CONFIG_FILES   CONFIG_BASE+2   /* File requester pattern for file requests    */
  143. #define CONFIG_CFGFPAT CONFIG_BASE+3   /* File requester pattern for config file      */
  144. #define CONFIG_EXT     CONFIG_BASE+4   /* Extension to put on all projects            */
  145. #define CONFIG_DCLICK  CONFIG_BASE+5   /* Command to execute for double click         */
  146. #define CONFIG_EDIT    CONFIG_BASE+6   /* Issue an edit command                       */
  147. #define CONFIG_CO      CONFIG_BASE+7   /* Command to issue to check out a file        */
  148. #define CONFIG_BUILD   CONFIG_BASE+8   /* Executed for BUILD option on command line   */
  149. #define CONFIG_EDPROJ  CONFIG_BASE+9   /* Edit command for project file               */
  150.  
  151. #define NUM_CONFIG     10    /* For range checking                             */
  152.  
  153. #define SUBRTN_BASE    CONFIG_BASE+NUM_CONFIG
  154. #define NUM_SUBRTN     12   /* Space for user defined routines                */
  155.  
  156. #define MAX_TEXT       SUBRTN_BASE+NUM_SUBRTN /* number of items in global.text */
  157.  
  158. #define FILE_ENV        1
  159. #define FILE_OPTIONS    2
  160. #define FILE_C          3
  161. #define FILE_DMAKEFILE  4
  162.  
  163. #define SYM_HOLD       "_FILE_"
  164. #define SYM_SCRIPT     "_SCRIPT_"
  165. #define SYM_REXXPORT   "_PORT_"
  166. #define SYM_CONFIG     "_CONFIG_"
  167. #define SYM_ORIG_CFG   "_ORIG_CFG_"
  168. #define SYM_REXXINTER  "_REXXINTER_"
  169.  
  170. /***************************************************************************/
  171. /*   Definition of objects used throughout VMake                           */
  172. /***************************************************************************/
  173. struct G_OBJECT {
  174.    struct G_OBJECT *next;   /* Next object in the list                     */
  175.                             /* Note you must cast to use based on the class*/
  176.    struct G_OBJECT *prev;   /* Previous object in the list.                */
  177.    char             class;  /* Class of the object                         */
  178.    char             state;  /* State (meaning is class based)              */
  179.                             /* Check: bool (is check selected?)            */
  180.                             /* Button: button's own index                  */
  181.                             /* List: Which (if any) string gadget selected */
  182.    char            *title;  /* Title associated with the object.           */
  183.    struct Gadget   *gadget; /* Intuition Gadget representing object        */
  184. };
  185.  
  186. struct G_STRING {
  187.    struct G_OBJECT  base;
  188.    char            *option;
  189.    char             buf[MAX_STRING];
  190.    char             clean_buf[MAX_STRING];    /* to detect DIRTY string */
  191. };
  192.  
  193. struct G_VALUE {
  194.    struct G_VALUE  *next;   /* Next cycle in the list                   */
  195.    char            *title;  /* Title to print for this value in a cycle */
  196.    char            *option; /* The option for this choice in the cycle  */
  197.    struct G_STRING *string; /* For those cycles supporting a string     */
  198. };
  199.  
  200. struct G_CYCLE {
  201.    struct G_OBJECT  base;   /* Base object information                  */
  202.    struct G_VALUE  *values; /* List of all possible values              */
  203.    struct G_VALUE  *curval; /* Current value                            */
  204. };
  205.  
  206. struct G_BUTTON {
  207.    struct G_OBJECT  base;   /* Base object information                  */
  208.    char            *command;/* Command for button to execute            */
  209. };
  210.  
  211. struct G_CHECK {
  212.    struct G_OBJECT  base;   /* Base object information                  */
  213.    char            *option0;/* Non-selected option value                */
  214.    char            *option1;/* Selected option value                    */
  215. };
  216.  
  217. struct G_ENTRY {
  218.    struct G_OBJECT  base;   /* Base object information                  */
  219.                             /* State information indicates that the entry */
  220.                             /* is a automatically generated entry that  */
  221.                             /* does not need to be distributed          */
  222.    char             buf[MAX_STRING]; /* Value for the current entry     */
  223. };
  224.  
  225. struct G_LIST {
  226.    struct G_OBJECT  base;   /* Base object information                  */
  227.                             /* State shows which item is selected       */
  228.    char            *option; /* Option value for all entries             */
  229.    struct G_ENTRY  *first;  /* First option in the list                 */
  230.    struct G_ENTRY  *top;    /* Top option being displayed               */
  231.    char            spare1;  /* Was 'string' bool, replaced by 'sel' ptr */
  232.    char              maxent;/* Number of entries in the list            */
  233.    struct Gadget   *delgad; /* The delete gadget                        */
  234.    struct Gadget   *slider; /* The proportional gadget                  */
  235.    struct Gadget   *strgad[MAX_LIST];  /* String gadgets for the list   */
  236.    struct Gadget   *btngad[MAX_LIST];  /* Button gadgets for the list   */
  237.    struct Border   *sborder;/* Border for any active strings            */
  238.    struct G_ENTRY  *sel;    /* Selected list entry, shown with border   */
  239. };
  240.  
  241. struct GADLIST {
  242.    struct Gadget *gadgets;
  243.    int            count;
  244. };
  245.  
  246. /***************************************************************************/
  247. /***************************************************************************/
  248. struct GLOBAL {
  249.    struct RenderInfo  ri;
  250.    struct Window     *window;
  251.    FILE              *fp;
  252.    struct Screen     *screen;
  253.    int                line;
  254.    int                state;
  255.    int                done;
  256.    int                newscreen;
  257.    int                unghost;
  258.    int                width;
  259.    int                height;
  260.    int                iheight;
  261.    int                eheight;  /* Height of an entry in a list */
  262.    int                boxx, boxy, boxw, boxh;
  263.    struct NewMenu     menuitem[MAX_MENU+1];
  264.    char               title[MAX_TITLE];
  265.    char               title2[MAX_TITLE];
  266.    struct G_BUTTON    button[MAX_BUTTON];
  267.    struct GADLIST     *gadlist;
  268.    struct G_OBJECT    *objects;            /* Base object list */
  269.    struct G_LIST      *filelist;
  270.    struct RastPort    *rp;
  271.    struct Border      *cycborder;
  272.    struct Border      *checkborder[2];
  273.    struct Border       arrowborder[2];
  274.    struct Menu        *menu;
  275.    int                cycsize;
  276.    int                titsize;
  277.    int                listsize; /* Number of string gads in list gad */
  278.    char               filename[MAX_FILENAME+1];
  279.    struct FileRequester *freq;
  280.    char               *text[MAX_TEXT];
  281.    int                listextra;
  282.    char               defbuf[MAX_STRING];
  283.    BPTR               homedir;     /* Initial home directory */
  284.    BPTR               workdir;     /* Work directory for all source */
  285.    int                rexxinter; /* rexx is in interactive mode */
  286.    int                inrexx;   /* currently processing a command from rexx */
  287.    int                rexxmsgs; /* interactive rexx, messages & RCs only */
  288.    int                rexxrc;   /* rexx return result code */
  289.    char               *rexxrs;  /* rexx result string */
  290.    int                parsefail; /* failed to read a config file */
  291.    int                dirtysym; /* true after SET command changes a symbol */
  292.    int                oldproject; /* true after READ, false after NEW */
  293.    int                mouseprop;  /* process prop gadget for mouse move */
  294.    int                cbufsize;  /* size of allocated command buffer */
  295.    char               *cbuf;     /* buffer for building commands */
  296. };
  297.  
  298. extern struct GLOBAL global;
  299.  
  300. /***************************************************************************/
  301. /* Stuff to make ARP work.                                                 */
  302. /***************************************************************************/
  303. #pragma libcall ArpBase ArpFileRequest 126 801
  304. #pragma libcall ArpBase ArpAllocFreq   294 000
  305.  
  306. extern struct FileRequester *ArpAllocFreq(void);
  307. extern char *ArpFileRequest(struct FileRequester *);
  308.  
  309. #define Prototype extern
  310. #include "VMake-protos.h"
  311.